import { mts } from '../types'

const state = () => ({
  logs: []
})

const mutations = {
  [mts.addLog]: (state, log) => {
    state.logs.push(log)
  },
  [mts.cleanLog]: (state) => {
    state.logs.splice(0)
  }
}

const actions = {
  addErrorLog({ commit }, log) {
    commit(mts.addLog, log)
  },
  clearErrorLog({ commit }) {
    commit(mts.cleanLog)
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
